var webpack = require('webpack');
var path = require('path');
var proxy = require('http-proxy-middleware');

module.exports = {
    //入口文件
    entry: './src/App.js',
    //出口文件
    output: {
        publicPath: '/dist/', //编译以后文件路径
        path: path.resolve(__dirname,'./'),  //一定是绝对路径
        filename: 'bundle.js', //文件名
    },
    module: {
        loaders: [ //加载器  webpack的核心
            {
                test: /\.js$/,
                loader: "babel-loader",
                query: {
                    presets: ['es2015', 'react', 'stage-0']
                }
            },
            {
                test:/\.scss$/,
                loader:['style','css','sass']
            },
            {
                test: /\.css$/,
                loaders: ['style-loader', 'css-loader']
            },
            {
                test: /\.(ttf|eot|svg|woff|woff2)(\?.+)?$/,
                loader: 'file-loader?name=[hash:12].[ext]'
            }
        ]
    },
    devServer: {
        proxy: {
            '/api': {
                target: 'http://api.douban.com',
                pathRewrite: {
                    '^/api': '/'
                },
                changeOrigin: true
            }
        }
    }
}